package com.tusuo.stds.util.validator;

import android.text.TextUtils;
import android.widget.EditText;

import com.andreabaccega.formedittextvalidator.Validator;

/**
 * @author J.Huang
 * @version 1.0
 *
 */

public class CaptchaValidator extends Validator {

    public CaptchaValidator(String _customErrorMessage) {
        super(_customErrorMessage);
    }

    @Override
    public boolean isValid(EditText et) {
        String captcha = et.getText().toString();
        // 4-6位验证码
        String captchaRegex = "^[0-9a-zA-Z]{4,6}$";
        if (TextUtils.isEmpty(captcha)) {
            return false;
        } else {
            return captcha.matches(captchaRegex);
        }
    }
}
